<template>
  <div id="name">
    <div class="wl-body">
      <div class="top"></div>

      <div class="topbox slideOut">
        <div class="bdds">
          <div class="txtsde txtc t-left">{{ $t("m.wkjl") }}</div>
          <div class="link-item bottml">
            <div class="zc-dj t-left">USDT</div>
            <div class="slink defcf">
              <div class="flex1">{{ $t("m.wkzl") }}</div>
              <div class="flex1"></div>
              <div class="flex1">{{ $t("m.zh") }}({{ bzdw }})</div>
            </div>
            <div class="slink u-dj">
              <div class="flex1">
                {{ see ? (s ? s.winCny.toFixed(4) : "0") : "*****" }}
              </div>
              <div class="flex1"></div>
              <div class="flex1">
                {{ see ? (s ? (s.winCny * utoc).toFixed(4) : "0") : "*****" }}
              </div>
            </div>
          </div>
          <div class="link-item">
            <div class="zc-dj t-left">TROT</div>
            <div class="slink defcf">
              <div class="flex1">{{ $t("m.dqwkzl") }}</div>
              <div class="flex1">{{ $t("m.wsf") }}</div>
              <div class="flex1">{{ $t("m.zh") }}({{ bzdw }})</div>
            </div>
            <div class="slink u-dj">
              <div class="flex1">
                {{
                  see
                    ? s
                      ? (s.winFt + s.releaseTotal).toFixed(4)
                      : "0"
                    : "*****"
                }}
              </div>
              <div class="flex1">
                {{ see ? (s ? s.winFt.toFixed(4) : "0") : "*****" }}
              </div>
              <div class="flex1">
                {{
                  see
                    ? s
                      ? ((s.winFt + s.releaseTotal) * ttoc).toFixed(4)
                      : "0"
                    : "*****"
                }}
              </div>
            </div>
          </div>
        </div>
      </div>

      <div>
        <div class="i-title t-left mtp">— {{ $t("m.jllb") }} —</div>
        <div class="mtp slink w31 xuankuang">
          <div
            class="xk1"
            :class="[acchange == 2 ? 'active' : '']"
            @click="changers(2)"
          >
            {{ $t("m.qb") }}
          </div>
          <div
            class="xk1"
            :class="[acchange == 0 ? 'active' : '']"
            @click="changers(0)"
          >
            USDT
          </div>
          <div
            class="xk1"
            :class="[acchange == 1 ? 'active' : '']"
            @click="changers(1)"
          >
            TROT
          </div>
        </div>
      </div>

      <div class="bdds slideIn" v-if="show">
        <van-list
          v-model="loading"
          :finished="finished"
          :finished-text="$t('m.nomore')"
          @load="onLoad(acchange)"
        >
          <div class="link-item bottml" v-for="(item, k) in yxlist" :key="k">
            <div class="slink defcf">
              <div class="flex1">{{ $t("m.sl") }}</div>
              <div class="flex1">{{ $t("m.bz") }}</div>
              <div class="flex1">{{ $t("m.sj") }}</div>
            </div>
            <div class="slink u-dj">
              <div class="flex1">
                {{ item.rewardDot > 0 ? item.rewardDot : ""
                }}{{ item.rewardUsdt > 0 ? item.rewardUsdt : "" }}
              </div>
              <div class="flex1">
                {{ item.rewardDot > 0 ? "TROT" : ""
                }}{{ item.rewardUsdt > 0 ? "USDT" : "" }}
              </div>
              <div class="flex1">{{ item.createDate }}</div>
            </div>
          </div>
        </van-list>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "name",
  data() {
    return {
      isPublish: false,
      show: true,
      acchange: 2,
      yxlist: [],
      loading: false,
      finished: false,
      pageNum: 1,
      see: "",
    };
  },
  created() {
    if (this.$store.getters.see == "0") {
      this.see = false;
    } else {
      this.see = true;
    }
  },
  computed: {
    s() {
      return this.$store.getters.s;
    },
    ttoc() {
      return this.$store.getters.ttoc;
    },
    utoc() {
      return this.$store.getters.utoc;
    },
    ttou() {
      return this.$store.getters.ttou;
    },
    bzdw() {
      if (this.$store.getters.language == "zh-CN") {
        return "CNY";
      } else {
        return "USD";
      }
    },
  },
  methods: {
    guanbi() {
      this.$router.go(-1);
    },
    changers(val) {
      this.acchange = val;
      this.show = false;
      this.pageNum = 1;
      this.yxlist = [];
      this.finished = false;
      this.onLoad(this.acchange);
    },
    onLoad(val) {
      if (this.$store.getters.nameid) {
        var datas = {
          params: {
            uid: this.$store.getters.nameid,
            pageSize: 10,
            pageNum: this.pageNum,
            winStatus: val,
          },
        };
        this.$get({
          url: "gms-history/getList",
          data: datas,
          callback: (data) => {
            this.$nextTick(function () {
              var list = data.data;
              if (list) {
                this.show = true;
                if (this.pageNum > 1) {
                  this.yxlist = [...this.yxlist, ...list];
                } else {
                  this.yxlist = list;
                }
                this.loading = false;
                if (list.length != 0) {
                  this.pageNum++;
                } else {
                  this.finished = true;
                }
              } else {
                this.$toast(data.msg);
              }
            });
          },
        }).catch(() => {
          this.$toast(this.$i18n.t("m.errordata"));
        });
      } else {
        this.getuid();
      }
    },

    getuid() {
      this.$get({
        url: "wms-wallet/user-game-info/" + this.$store.getters.userWallet,
        data: {},
        callback: (data) => {
          this.$nextTick(function () {
            if (data.data) {
              this.$store.commit("nameid", data.data.id);
              this.onLoad();
            }
          });
        },
      }).catch(() => {
        this.$toast(this.$i18n.t("m.errordata"));
      });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>